import {request} from "../request";
import {utils} from "../../common/utils";

//1.获取所有岗位选项
export function getPositionOptions() {
    return request({
        url: '/sys/position/options',
        method: 'get'
    })
}

//1.根据部门查询岗位
export function getPosByDeptId(did) {
    console.log("did - > " , did)
    return request({
        url: '/sys/position/bydept',
        method: 'get',
        params: {did}
    })
}

//1.查询岗位
export function getPositionList({keyword,status,start,end,pageNum,pageSize}){
    return request({
        url: '/sys/position/query',
        method: 'get',
        params:{
            keyword,
            status,
            start,
            end,
            pageNum,
            pageSize,
        }
    })
}

//2.修改岗位
export function updatePosition(position){
    return request({
        url: '/sys/position/update',
        method: 'put',
        data: position
    })
}

//3.新增岗位
export function addPosition(position){
    console.log(" --- > " , position)
    return request({
        url: '/sys/position/add',
        method: 'post',
        data: position
    })
}

//4.删除岗位
export function deletePosition(ids){
    let strUrl = utils.joinArrayReqParam(ids,'ids');
    return request({
        url: '/sys/position/delete' + strUrl,
        method: 'delete'
    })
}

//5、查询是否存在有相同名称的岗位
export function hasSomeNamePosition({id,name}){
    return request({
        url: '/sys/position/has-some-name',
        method: 'get',
        params:{
            id,
            name
        }
    })
}

//6、查询是否存在有相同编号的岗位
export function hasSomeCodePosition({id,code}){
    return request({
        url: '/sys/position/has-some-code',
        method: 'get',
        params: {
            id,
            code
        }
    })
}